<template>
    <section>
            <sy-baselist
                    ref="main"
                    :filters="filters"
                    hideOperate
                    hideAdd
                    hidePagination
                    @beforeSearch="beforeSearch"
                    listUrl="server/report/Report.ashx?cmd=GetTeamReport"
            >
                <el-table-column prop="UserName"  align="center"  header-align="center" label="团队名"   width="120" >
                    <template scope="scope">
                        <a href="javascript:;" @click="viewUser(scope.row)">{{ scope.row.UserName }}</a>
                    </template>
                </el-table-column>
                <el-table-column prop="Count0" align="center"  header-align="center" label="电话量"  sortable width="120" >
                </el-table-column>
                <el-table-column prop="Count4" align="center"  header-align="center" label="有效电话量"  sortable width="120" >
                </el-table-column>
                <el-table-column prop="Count1"  align="center"  header-align="center" label="新增意向客户数"  sortable width="160" >
                </el-table-column>
                <el-table-column prop="Count2"  align="center" header-align="center" label="已发合同客户数"  sortable width="160" >
                </el-table-column>
                <el-table-column prop="Count3"  align="center"  header-align="center" label="实际签合同客户数" sortable  width="170" >
                </el-table-column>
                <template v-if="topName" slot="extendbtnTop">
                    <el-button @click="back" type="success" size="small" icon="caret-left">返回</el-button>
                </template>
            </sy-baselist>
    </section>
</template>

<script>
    import util from '../../common/util'
    import mixin from '../../common/mixin'
    import ViewTelTrace from './ViewTelTrace.vue'
    import ViewTrace from './ViewTrace.vue'
    export default {
        mixins: [mixin],
        components:{
            ViewTelTrace:ViewTelTrace,
            ViewTrace:ViewTrace,
        },
        data(){
            /* //默认本月时间
             let start = util.date.getDate()
             let end =  util.date.getDate()
             start.setDate(1)
             util.date.addMonth(end,1)
             end.setDate(1)
             util.date.addDay(end,-1)
             */
            //默认当天
            let start = util.date.getDate()
            let end =  util.date.getDate()
            return {
                topName:"",
                filters: [
                    {type: "date",name:"FCreateDate",text:"统计时间", value: [start,end]}
                ]
            }
        },
        methods:{
            beforeSearch(para){
                if(this.topName){
                    if(para.oWhere){
                        para.oWhere.topName = this.topName
                    }
                }
            },
            back(){
                this.$router.go(-1)
            },
            viewUser(row){
                let FCreateDate = this.filters[0].value
                let startDate = null;
                let endDate = null;
                if(FCreateDate && FCreateDate.length>1){
                      startDate = FCreateDate[0]
                      endDate = FCreateDate[1]
                }
                this.$router.push({path: '/ReportAll',
                    query: { teamName: row.UserName,
                             startDate: util.date.format(startDate,"yyyy-MM-dd"),
                             endDate:   util.date.format(endDate,"yyyy-MM-dd")
                }})
            }
        },
        created(){
            this.topName = this.$router.currentRoute.query.topName
            let startDate = this.$router.currentRoute.query.startDate
            let endDate = this.$router.currentRoute.query.endDate
            if(startDate && endDate){
                this.filters[0].value = [util.date.parse(startDate,"yyyy-MM-dd"),
                                         util.date.parse(endDate,"yyyy-MM-dd")]
            }
        }
    }
</script>
